import java.util.Arrays;

public class Test {
    public static void main(String[] args) {
        int[] A = {1, 2, 3};
        int[] B = {2, 5, 6};
//        int[] newArr = merge(A,3,B,4);
//        for (int i = 0; i < newArr.length; i++) {
//            System.out.print(newArr[i]+" ");
//        }
        merge(A, 3, B, 4);
    }
    //合并两个有序链表
    public static void merge(int[] A, int m, int[] B, int n) {
        m = A.length;
        n = B.length;
        int[] arr = new int[m + n];
        int i = 0;
        int j = 0;
        int k = 0;
        while (i < m || j < n) {
            if (i == m && j < n) {
                arr[k++] = B[j++];
            } else if (i < m && j == n) {
                arr[k++] = A[i++];
            } else if (A[i] <= B[j]) {
                arr[k++] = A[i++];
            } else if (A[i] > B[j]) {
                arr[k++] = B[j++];
            }
        }
        for (int x : arr) {
            System.out.print(x);
        }
    }

}
